package com.liugege.make.builder.buildcar;

import java.util.ArrayList;
import java.util.List;

public abstract class BeanCar {

    private String carName;
    private String description;
    private List<String> sequence = new ArrayList<>();

    public BeanCar() {
    }

    public BeanCar(String carName, String description) {
        this.carName = carName;
        this.description = description;
    }

    public String getCarName() {
        return carName;
    }

    public void setCarName(String carName) {
        this.carName = carName;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public final void setSequence(List<String> sequence) {
        this.sequence = sequence;
    }

    //启动
    public abstract void start();
    //停止
    public abstract void stop();
    //鸣号
    public  abstract void alarm();
    //引擎发动
    public abstract void engineBoom();

    public  final void run (){
        for (int i = 0; i < sequence.size(); i++) {
            String actionName = this.sequence.get(i);
            if ("start".equalsIgnoreCase(actionName)){
                this.start();
            }else if ("stop".equalsIgnoreCase(actionName)){
                this.stop();
            }else if ("alarm".equalsIgnoreCase(actionName)){
                this.alarm();
            }else if ("engineBoom".equalsIgnoreCase(actionName)){
                this.engineBoom();
            }
        }
    }


    @Override
    public String toString() {
        return "BeanCar{" +
                "carName='" + carName + '\'' +
                ", description='" + description + '\'' +
                '}';
    }

}
